import { OperateBase } from '../../common/operate-base';
import { Select } from '../../../cors/select';
import { SelectPlugin } from '../../../pugins/select.plugin';
export class Unselect extends OperateBase {
    protected container: HTMLElement;
    protected selectPlugin: SelectPlugin;
    constructor() {
        super();
    }
    public selectChange() {

    }
    public afterDomInit() {
        this.selectPlugin = this.zTableInstance.pluginManager.getPlugin('SelectPlugin') as SelectPlugin;
        this.zTableInstance.getHook().afterSelect.add(() => {
            this.checkSeleced();
        });
        this.checkSeleced();
    }
    public getDom() {
        this.container = document.createElement('div');
        this.container.setAttribute('class', this.containerClassName);
        this.container.innerHTML=`<span class="z-tools-icon icon iconfont icon-select-off"></span>`;
        this.container.querySelector('.icon-select-off').addEventListener('click', () => {
            this.selectPlugin.clear();
            this.checkSeleced();
        });
        return this.container;
    }
    protected checkSeleced() {
        let iconEle =  this.container.querySelector('.icon-select-off') as HTMLElement;
        if(this.selectPlugin.getSelect() === null) {
            iconEle.classList.add('z-table-icon-disabled');
        } else {
            iconEle.classList.remove('z-table-icon-disabled');
        }
    }
}